<template>
    <el-dropdown trigger="click">
        <el-avatar :src='user.avatarUrl' />
        <template #dropdown>
            <el-dropdown-menu>
                <el-dropdown-item :icon="UserFilled" @click="toUserInfo()">
                    个人信息
                </el-dropdown-item>
                <el-dropdown-item :icon="Unlock">
                    密码修改
                </el-dropdown-item>
                <el-dropdown-item :icon="Right"  @click = "logout() ">
                    退出登录
                </el-dropdown-item>
            </el-dropdown-menu>
        </template>
    </el-dropdown>
</template>
<script setup lang="ts" >
import { UserFilled, Right, Unlock } from '@element-plus/icons-vue'
import { useRouter } from "vue-router"
import { useUserInfo } from '@/stores/admin/index'
import { get, post } from '@/utils/https'
import cookie from "js-cookie";
import { ElMessage } from 'element-plus/lib/components/index.js';
const { user } = useUserInfo()
const router = useRouter()
const toUserInfo = () => {
    router.push("/index/user/userInfo")
}
function logout() {
    // --url /m.api?_gp=user&_mt=logout&ACCESSTOKEN= 
    const token = cookie.get('token')
    let data = {
        _gp:"admin",
        _mt:"logout",
    }
    get(data).then(res=>{
        console.log(res);
        if (res.data=='ok') {
            ElMessage.success("退出登录！")
            // router.replace({ path: "/login", query: { back: fullPath }})
        }
    })
    
}
</script>



